package gui;

import java.awt.event.ActionEvent;
import java.util.Observable;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JOptionPane;

public class SwitchUserControl extends Observable {
	JButton myButton;
	String[] myOptions = {"Yes", "Cancel"};
	public SwitchUserControl() {
		myButton = new JButton( 
		new AbstractAction("Switch User") {
			@Override
			public void actionPerformed(ActionEvent e) {
				int selection =
					JOptionPane.showOptionDialog(null, 
							"Switch Users", 
							"Do you want to select " +
							"a different user?", 
							JOptionPane.OK_CANCEL_OPTION, 
							JOptionPane.QUESTION_MESSAGE, 
							null, 
							myOptions, 
							0);
					
				switch (selection) {
				case 0:
					// save conference
					setChanged();
					notifyObservers(State.SWITCH_USER);
					break;
				default:
					// do nothing
					break;
				}
			}
		});
	}
	
	public JButton getButton() {
		return myButton;
	}
}
